package com.xyh.flowershop.controller;

import com.xyh.flowershop.service.TipDictService;
import com.xyh.flowershop.service.TipService;
import com.xyh.flowershop.vo.req.tip.TipAddReqVo;
import com.xyh.flowershop.vo.req.tip.TipDictEditReqVo;
import com.xyh.flowershop.vo.resp.common.ResultRespVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @author 小约翰可汗
 * @className TipController
 * @createTime 2024/7/717:18
 */
@Slf4j
@RestController
@RequestMapping("/tip/")
@Tag(name = "举报接口")
@CrossOrigin(origins = "*", maxAge = 3600)
public class TipController {

    private final TipService tipService;

    private final TipDictService tipDictService;

    public TipController(TipService tipService, TipDictService tipDictService) {
        this.tipService = tipService;
        this.tipDictService = tipDictService;
    }

    @Operation(summary = "添加或编辑举报类型")
    @PostMapping("addOrEdit")
    public ResultRespVo addOrdEditTipDict(@RequestBody TipDictEditReqVo vo){
        tipDictService.addOrEditTipDict(vo);
        return ResultRespVo.success();
    }

    @Operation(summary = "查询举报类型列表")
    @GetMapping("findTipDictList")
    public ResultRespVo findTipDictList(){
        return ResultRespVo.success(tipDictService.findTipDictList());
    }

    @Operation(summary = "提交举报")
    @PostMapping("addTip")
    public ResultRespVo addTip(@RequestBody TipAddReqVo vo) {
        return ResultRespVo.success(tipService.submitTip(vo));
    }



}
